/*
   Copyright (c) 2019 Shanghai Xuanzi Technology Co. Ltd https://xuanzi.ltd
   XZMindMap is licensed under the Mulan PSL v1.
   You can use this software according to the terms and conditions of the Mulan PSL v1.
   You may obtain a copy of Mulan PSL v1 at:
      http://license.coscl.org.cn/MulanPSL
   THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
   PURPOSE.
   See the Mulan PSL v1 for more details.

*/

package xuanzi.commons.graphics;

public class PointBuffer {

	int pos = -1;
	
	PointF[] points;
	
	public PointBuffer(int count) {
		points = new PointF[count];
		for(int i=0;i<points.length;i++) {
			points[i] = new PointF();
		}
	}
	
	public void reset() {
		pos = -1;
	}
	
	public PointF get(PointF point) {
		if(true)
			return point;
		if(pos>=points.length)
			pos = 0;
		if(pos==-1) { 
			for(int i=0;i<points.length;i++) {
				points[i] = new PointF();
				points[i].x = point.x;
				points[i].y = point.y;
			}
			pos =0;
			return point;
		}else {
			points[pos].x = point.x;
			points[pos].y = point.y;
			pos++;
			
			{
				
				for(int i=0;i<points.length;i++) {
					point.x += points[i].x;
					point.y += points[i].y;
				}
				point.x = point.x/points.length;
				point.y = point.y/points.length;
			}
			return point;
		}
	}

}
